<body>
<div class="divmain">
<table width="100%" id="fmfrmreportdetail_tblinfo" class="tblInfo">
<tr>
<td valign="top" class="width25">
<div>
<table class="info" id="frmreportdetail_tblcondition">
 
 <tr>
<td colspan="2">
Xóa thông tin chi tiết đến trước ngày
</td>
</tr>
<tr>
<td >
<input type="text" value="" maxlength="10" onblur="formatddmmyyyy(this)" style="width:80px" maxlength="10"  id="fmfrmreportdetail_dateDelete"/>
<a href="javascript:fmfrmreportdetail_cal3.popup();">
<img src="adagps.com/images/cal/cal2.png" id="fmfrmreportdetail_imgCal3"  class="datepicker dpkstart" ></a>
</td>
<td>
<button id="fmfrmreportdetail_btnDelete" onclick="fmfrmreportdetail_deleteDetail()" class="width100">Xóa dữ liệu chi tiết</button>
</td>
</tr>

<tr>
<td colspan="2" style="border-bottom:thin solid #000000;"></td></tr>

<tr><td width="40%">Gửi sms chi tiết:</td><td style="text-align:right">
 <button id="fmfrmreportdetail_smsSend" class="smsSend width100" onclick="fmfrmreportdetail_smsSend();" type="button"> Gửi </button>
</td></tr>
<tr>
<td colspan="2" style="border-bottom:thin solid #000000;"></td></tr>




<tr >
<td colspan="2">
<div id="fmfrmreportdetail_divleft" class="divleft"> 
<table class="width100" style="background-color:transparent">

 
<tr><td>TG kết thúc từ:</td>
<td><input type="text" value="" onblur="formatddmmyyyy(this)" style="width:140px" maxlength="19"  id="fmfrmreportdetail_fromdate"/><a href="javascript:fmfrmreportdetail_cal1.popup();">
<img src="adagps.com/images/cal/cal2.png" id="fmfrmreportdetail_imgCal1"  class="datepicker dpkstart" ></a>
</td></tr>
<tr>
<td>TG kết thúc đến:</td>
<td>
<input type="text"  value="" onblur="formatddmmyyyy(this)"  id="fmfrmreportdetail_todate" style="width:140px" maxlength="19" /><a href="javascript:fmfrmreportdetail_cal2.popup();">
<img src="adagps.com/images/cal/cal2.png" id="fmfrmreportdetail_imgCal2"    class="datepicker dpkend" ></a>  </td>
</tr>
<tr><td rowspan="4">Loại báo cáo:</td><td ><input type="radio" checked="checked"  name="fmfrmreportdetail_reporttype" id="fmfrmreportdetail_reporttype_4" value="4">Theo Hóa Đơn</input></td></tr>
<tr><td colspan="2"><input type="radio"  name="fmfrmreportdetail_reporttype" id="fmfrmreportdetail_reporttype_2" value="2">Theo Sản Phẩm</input></td></tr>
<tr><td colspan="2"><input type="radio"  name="fmfrmreportdetail_reporttype" id="fmfrmreportdetail_reporttype_1" value="1">Theo Bàn</input></td></tr>
<tr><td colspan="2"><input type="radio"  name="fmfrmreportdetail_reporttype" id="fmfrmreportdetail_reporttype_3" value="3">Theo Người Thu</input></td></tr>


</table>
    <div class="divactionbuton">
        <button id="fmfrmreportdetail_create" class="bntreport" onclick="fmfrmreportdetail_createReport();" type="button"> Xem </button>
        </div>
</div>
</td>
</tr>  

</table>
</div>
</td>
<td class="clsmiddle"></td>

<td width="80%" height="400" valign="top">
<div class="divGrid" id="fmfrmreportdetail_divGrid">
 
</div>

<div  id="fmfrmreportdetail_divsms"  style="width:600px" align="center">
<table class="width100">
<tr>
<td style="text-align:right">(Các) số điện thoại :
</td>
<td><input id="fmfrmreportdetail_txtphonenumber" maxlength="50" type="text" class="width100"/>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">NỘI DUNG TIN NHẮN
</td>
</tr>
<tr>
<td style="text-align:right">Tiền sản phẩm:
</td>
<td id="fmfrmreportdetail_doanhthusms">
</td>
</tr>
<tr>
<td style="text-align:right" class="lblRequired">Từ:
</td>
<td id="fmfrmreportdetail_timeFrom">
</td>
</tr>
<tr>
<td style="text-align:right" class="lblRequired"> Đến:
</td>
<td id="fmfrmreportdetail_timeTo">
</td>
</tr>
<tr>
<td rowspan="3" style="color:blue;text-align:right">  Chú ý:   
</td>
<td style="color:blue">
- Có thể nhắn tin nhiều số điện thoại cùng lúc.
</td>
</tr>
<tr>
<td style="color:blue">
- Các số điện thoại phải cách nhau dấu ';' . 
</td>
</tr>
<tr>
<td style="color:blue">
- Phí dịch vụ mỗi tin nhắn là 1000 vnđ/1 số điện thoại 
</td>

<tr>
<td colspan="2">  <button id="fmfrmreportdetail_confirm" class="bntreport" onclick="fmfrmreportdetail_confirm();" type="button"> Xác nhận </button> 
 <button id="fmfrmreportdetail_confirm" class="cancelDialog" type="button"> Bỏ qua </button>  
</td>
</tr>

</table>
</div>
</td>
<td class="clsend"></td>
</tr>
</table>
</div>
</body>

<script language="javascript">
changeWaiting(0);
  var fmfrmreportdetail_smscontent = '' ; 
 $(document).ready(function () {
    initForm('fmfrmreportdetail_tblinfo'); 
    initDivleft();
    $('#fmfrmreportdetail_divsms').dialog({
        autoOpen: false,
        title: 'Gửi sms thông tin chi tiết',
        modal:true,
        width: 600,
        resizable: true,
        overflow: 'auto'
    });   
});
 var fmfrmreportdetail_cal1 = CreateCalObject('fmfrmreportdetail_fromdate', 'fmfrmreportdetail_imgCal1');
var fmfrmreportdetail_cal2 = CreateCalObject('fmfrmreportdetail_todate', 'fmfrmreportdetail_imgCal2');
var fmfrmreportdetail_cal3 = CreateCalObject('fmfrmreportdetail_dateDelete', 'fmfrmreportdetail_imgCal3');
 fmfrmreportdetail_cal1.time_comp = true;
 fmfrmreportdetail_cal2.time_comp = true;
 fmfrmreportdetail_cal3.time_comp = false;
function fmfrmreportdetail_createReport(){
     room = $('#fmfrmreportdetail_cbbroom').val();
     if(!checkDate('fmfrmreportdetail_fromdate','fmfrmreportdetail_todate',7)){
        return false;
     } 
     fromdate = ConvertoDateEN($('#fmfrmreportdetail_fromdate').val());
     todate = ConvertoDateEN($('#fmfrmreportdetail_todate').val());
     reporttype = $('INPUT[NAME=fmfrmreportdetail_reporttype]:checked').val();
     changeWaiting(0);
     xajax_fmfrmreportdetail_load(fromdate,todate,reporttype);  
}

$('#fmfrmreportdetail_fromdate').val(GetCurrentDateTime(0,0,true,0)) ;
$('#fmfrmreportdetail_todate').val(GetCurrentDateTime(0,0,true,2)) ;
$('#fmfrmreportdetail_dateDelete').val(GetCurrentDateTime(0,1,false,0)) ;

function fmfrmreportdetail_openDetail(generate_id,timebegin,timeend,roomname){
  $('#fmfrmreportdetail_productDetail').dialog('option', 'title', 'Chi tiết sản phẩm phòng '+roomname+' từ '+ timebegin +' đến' + timeend);   
  xajax_fmfrmreportdetail_productDetail(generate_id);
}


function fmfrmreportdetail_deleteDetail(){
    var dateDelete = $('#fmfrmreportdetail_dateDelete').val();
    if(!isDate(dateDelete)){
        alert('Vui lòng nhập chính xác ngày xóa thông tin');
        $('#fmfrmreportdetail_dateDelete').focus();
        return false;
    }
    if(confirm('Chắc chắn xóa dữ liệu chi tiết đến trước ngày '+dateDelete+'?')){
      var dateDelete = ConvertoDateEN(dateDelete);
      xajax_fmfrmreportdetail_deleteDetail(dateDelete);  
    }
    
}

function fmfrmreportdetail_smsSend(){   
   if(checkStatusSMS()){
       $('#fmfrmreportdetail_divsms').dialog('open');
   } 
   
} 

function fmfrmreportdetail_confirm(){ 

   var $phonenumber = $('#fmfrmreportdetail_txtphonenumber').val();
      if($phonenumber.length==0){
          alert('Vui lòng nhập số điện thoại cần gửi');
          $('#fmfrmreportdetail_txtphonenumber').focus();
          return;
      } 
   var arrPhone = new Array();
   arrPhone = $phonenumber.split(";");

   flg = true; 
   for(var i = 0;i<arrPhone.length;i++){
     if(!ExpInteger.test(arrPhone[i])){
         flg = false;
         break;
     }  
   }
   if(!flg){
     alert('Vui lòng nhập (các) số điện thoại cho chính xác');
          $('#fmfrmreportdetail_txtphonenumber').focus();
          return;  
   }   
   xajax_fmfrmreportdetail_saveSMS($phonenumber,fmfrmreportdetail_smscontent);   
}

changeWaiting(0);
fmfrmreportdetail_createReport();
xajax_fmfrmreportdetail_setPhonenumber(); 
 </script>

